From f74d57e61ad22db67847bb202b016672d661ef9b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 1 Mar 2020 20:14:23 +0000 Subject: [PATCH] d/run-with-locales: Improve Gbp-Dch: ignore --- debian/rules | 6 ++--- debian/run-with-locales | 50 ++++++++++++++++++++++++------------ debian/tests/installed-tests | 6 ++--- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/debian/rules b/debian/rules index 3066dea9bb..52b2afd5df 100755 --- a/debian/rules +++ b/debian/rules @@ -184,9 +184,9 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) env -u LD_PRELOAD \ xvfb-run -a -s "-screen 0 1024x768x24" \ debian/run-with-locales \ - --generate de_DE.utf8 \ - --generate en_GB.utf8 \ - --generate en_US.utf8 \ + --generate de_DE.UTF-8 \ + --generate en_GB.UTF-8 \ + --generate en_US.UTF-8 \ --generate sv_SE \ -- \ dh_auto_test --builddirectory=debian/build/deb -- -k 0 -j 1 || true diff --git a/debian/run-with-locales b/debian/run-with-locales index 8f4aa0208e..5adb42d15c 100755 --- a/debian/run-with-locales +++ b/debian/run-with-locales @@ -44,48 +44,64 @@ usage () { exec >&2 fi - echo "Usage: $me [--generate LOCALE...] COMMAND [ARGS...]" + echo "Usage: $me [--generate LOCALE...] [--] COMMAND [ARGS...]" + exit "$status" } -getopt_temp=+help +getopt_temp=help getopt_temp="$getopt_temp,generate:" -getopt_temp="$(getopt -o '' --long "$getopt_temp" -n "$0" -- "$@")" +getopt_temp="$(getopt -o '+' --long "$getopt_temp" -n "$0" -- "$@")" eval set -- "$getopt_temp" unset getopt_temp generate () { local locale="$1" - local name local charset + local source + local output - case "$locale" in - (*.utf8) - name="${locale%.utf8}" - charset=UTF-8 - ;; + echo "$me: $locale..." >&2 - (sv_SE) - name="$locale" - charset=ISO-8859-1 + case "$locale" in + (*.*) + source="${locale%.*}" + output="$source.$( + export LC_ALL=C + printf '%s' "${locale##*.}" | \ + tr '[:upper:]' '[:lower:]' | \ + tr -d -C '[:lower:][:digit:]' + )" ;; (*) - echo "$me: Unsupported locale $locale" >&2 - exit 1 - ;; + source="${locale}" + output="${locale}" esac - if [ -e "/usr/lib/locale/$locale/LC_MESSAGES/SYS_LC_MESSAGES" ]; then + if [ -e "/usr/lib/locale/$output/LC_MESSAGES/SYS_LC_MESSAGES" ]; then + printf '\t%s\n' "Found in locales-all" >&2 return fi + charset=$(sed -ne "s/^$locale //p" /usr/share/i18n/SUPPORTED) + + if [ -z "$charset" ]; then + echo "$me: $locale not found in /usr/share/i18n/SUPPORTED" >&2 + exit 1 + fi + + printf '\t%s\n' "Character set: $charset" >&2 + printf '\t%s\n' "Source file: $source" >&2 + if [ -z "$tempdir" ]; then tempdir="$(mktemp -d)" trap 'rm -fr "$tempdir"' EXIT fi - localedef -i "$name" -f "$charset" "$tempdir/$locale" + printf '\t%s\n' "Output: $tempdir/$output" >&2 + + localedef -i "$source" -f "$charset" "$tempdir/$output" } while [ "$#" -gt 0 ]; do diff --git a/debian/tests/installed-tests b/debian/tests/installed-tests index 426a33130a..83b57ea25e 100755 --- a/debian/tests/installed-tests +++ b/debian/tests/installed-tests @@ -14,9 +14,9 @@ export XDG_RUNTIME_DIR="$AUTOPKGTEST_TMP" exec dbus-run-session -- \ xvfb-run -a -s "-screen 0 1024x768x24" \ debian/run-with-locales \ - --generate de_DE.utf8 \ - --generate en_GB.utf8 \ - --generate en_US.utf8 \ + --generate de_DE.UTF-8 \ + --generate en_GB.UTF-8 \ + --generate en_US.UTF-8 \ --generate sv_SE \ -- \ gnome-desktop-testing-runner \ -- 2.30.2